import re
from google.appengine.ext import db
from google.appengine.ext import search
from datetime import datetime

##################################################################################
#                                                                                #
#                       Models                                                   #
#                                                                                #
##################################################################################


class Feed(db.Model):
  url = db.StringProperty(required = True)
  tier = db.IntegerProperty(default = 1)
  last_retrieved = db.DateTimeProperty(default = datetime.fromtimestamp(0))
  lang = db.StringProperty(required = True)
  sourceName = db.StringProperty(required = True)
  country =  db.StringProperty(required = True)


class ConfigValue(db.Model):
  value = db.StringProperty()


class Domain(db.Model):
  domain = db.StringProperty(required = True)
  pubDate = db.DateTimeProperty(auto_now = True)


class Original(db.Model):
  id = db.IntegerProperty()
  title = db.StringProperty(required = True)
  url = db.LinkProperty(required = True)
  sourceName = db.StringProperty()
  country =  db.StringProperty(required = True)
  content = db.TextProperty()
  author = db.StringProperty()
  date = db.DateTimeProperty(auto_now_add = True)
  year = db.IntegerProperty()
  month = db.IntegerProperty()
  day = db.IntegerProperty()
  lang = db.StringProperty(required = True)
  pubDate = db.DateTimeProperty(auto_now = True)


class Item(db.Model):
  id = db.IntegerProperty()
  sid = db.IntegerProperty()
  title = db.StringProperty(required = True)
  url = db.LinkProperty(required = True)
  sourceName = db.StringProperty()
  country =  db.StringProperty(required = True)
  content = db.TextProperty()
  author = db.StringProperty()
  date = db.DateTimeProperty(auto_now_add = True)
  year = db.IntegerProperty()
  month = db.IntegerProperty()
  day = db.IntegerProperty()
  lang = db.StringProperty(required = True)
  pubDate = db.DateTimeProperty(auto_now = True)

  